/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package it.davial.mgwt.client.activities.patient;

import it.davial.mgwt.client.Patient;
import it.davial.mgwt.client.activities.BaseViewImpl;
import it.davial.mgwt.client.resources.ResourceAware;
import it.davial.mgwt.client.ui.widget.PatientCellList;
import it.davial.mgwt.client.ui.widget.cell.PatientCell;
import it.davial.mgwt.client.ui.widget.search_form.SearchForm;

import java.util.Date;
import java.util.List;

import org.soul.mgwt.client.widget.CsEditableCellList;

import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers;
import com.googlecode.mgwt.ui.client.widget.buttonbar.ButtonBar;
import com.googlecode.mgwt.ui.client.widget.buttonbar.ComposeButton;
import com.googlecode.mgwt.ui.client.widget.buttonbar.PlusButton;
import com.googlecode.mgwt.ui.client.widget.buttonbar.SearchButton;

/**
 * Sample implementation of {@link PatientView}.
 */
public class PatientViewImpl extends BaseViewImpl implements PatientView,ResourceAware {

//	private static final Logger logger = Logger.getLogger("PatientViewImpl");
	private PlusButton bAdd;
	private SearchButton bSearch;
	private ComposeButton bEdit;
	private PatientCellList list;
	private SearchForm searchForm;
	public PatientViewImpl() {
			bAdd = new PlusButton();
			bSearch = new SearchButton();
			bEdit = new ComposeButton();
			searchForm = new SearchForm();
			ButtonBar bb = new ButtonBar();
			bb.setStyleName(mainCss.getMainCss().buttonBar());
			bb.add(bAdd);
			bb.add(bSearch);
			bb.add(bEdit);
			
			headerPanel.setRightWidget(bb);
			scrollPanel.setScrollingEnabledX(false);
			
			main.remove(scrollPanel);
			main.add(searchForm);
		//	main.add(list);
	}
	@Override
	public HasTapHandlers getAddButton() {
		return bAdd;
	}
	@Override
	public HasTapHandlers getEditButton() {
		return bEdit;
	}
	@Override
	public void setPatients(List<Patient> patients) {
		list.render(patients);
		
	}
	@Override
	public void setPatientCellList(PatientCellList list) {
		this.list = list;
		main.add(scrollPanel);
		scrollPanel.setWidget(list);
		
		
	}
	@Override
	public String getSurname() {
		return searchForm.getSurname();
	}
	@Override
	public Date getDate() {
		return searchForm.getDate();
	}
	@Override
	public HasTapHandlers getSearchButton() {
		return bSearch;
	}
	
}
